﻿using ViewMaker.Core.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ViewMaker.Core;
using System.Collections.Generic;
using System.Windows.Controls;

namespace ViewMaker.Core.Tests
{
    public class UserTestControl : UserControl
    {
    }

    [TestClass()]
    public class UserControlViewControlTest
    {

        [TestMethod()]
        public void 標準的なUserControlのXAML生成()
        {
            var target = new UserControlViewControl { Width = 100, Item = new ViewLayoutItem { Name = "uc001", BindPath = "data", Caption="" } };
            target.TypeName = typeof(UserTestControl).AssemblyQualifiedName;
            var parent = TestHelper.CreateTestParent();
            parent.AppendChild(target.CreateXaml(parent)[1]);
            var xaml = parent;

            var actual = (UserControl)((ContentControl)TestHelper.GetFrameworkElement<ContentControl>(xaml).Content).Content;
            Assert.AreEqual("uc001", actual.Name);
            Assert.AreEqual("data", actual.GetBindingExpression(UserControl.DataContextProperty).ParentBinding.Path.Path);

        }

        [TestMethod()]
        public void UserControlViewControlの編集画面が表示可能()
        {
            var target = new UserControlViewControl { Width = 100, Item = new ViewLayoutItem { Name = "uc001", BindPath = "data", Caption = "" } };
            target.TypeName = typeof(UserTestControl).AssemblyQualifiedName;
            var baml = ViewUtil.BuildContent(target);
            Assert.IsNotNull(baml);
        }

    }
}
